<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:84:"F:\phpstudy_pro\WWW\www.danganguanli.com\public/../wcapps/admin\view\files\edit.html";i:1637909794;}*/ ?>
<!DOCTYPE html>

<html>

    <head>

        <meta charset="utf-8">

        <title>

           编辑文件

        </title>

        <meta name="renderer" content="webkit">

        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

        <meta name="apple-mobile-web-app-status-bar-style" content="black">

        <meta name="apple-mobile-web-app-capable" content="yes">

        <meta name="format-detection" content="telephone=no">

        <link href="/static/skin/nei.css" type="text/css" rel="stylesheet">  
    </head>

</head>

<body onLoad="initPage()">

<div id="LoadingBar"><img src="/static/images/load.gif" /></div>

<div class="d_contaiter">   

<form class="layui-form layui-form-pane" action="<?php echo url('admin/files/edit'); ?>" method="post" enctype="multipart/form-data">   
  <div class="layui-form-item">
    <label class="layui-form-label">所属大类*</label>
    <div class="layui-input-inline">
      <select name="cid" lay-verify="required" lay-filter="cid"   lay-search="">
        <option value="">搜索或直接选择,勿打字</option>
        <?php if(is_array($cateRes) || $cateRes instanceof \think\Collection || $cateRes instanceof \think\Paginator): $i = 0; $__LIST__ = $cateRes;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cate): $mod = ($i % 2 );++$i;?>
          <option value="<?php echo $cate['id']; ?>" <?php if($cate['id'] == $data['cid']): ?> selected="selected" <?php endif; ?>><?php echo $cate['name']; ?></option>
        <?php endforeach; endif; else: echo "" ;endif; ?>
      </select>
    </div>
    <label class="layui-form-label">所属小类*</label>
    <div class="layui-input-inline">
      <select name="sid" id="sid" lay-verify="required" lay-search="">
        <option value="">搜索或直接选择,勿打字</option>
         <?php if(is_array($cateRes2) || $cateRes2 instanceof \think\Collection || $cateRes2 instanceof \think\Paginator): $i = 0; $__LIST__ = $cateRes2;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cate): $mod = ($i % 2 );++$i;?>
          <option value="<?php echo $cate['id']; ?>" <?php if($cate['id'] == $data['sid']): ?> selected="selected" <?php endif; ?>><?php echo $cate['name']; ?></option>
        <?php endforeach; endif; else: echo "" ;endif; ?>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">选择文件</label>
     <div class="layui-input-inline" style="width: 360px">
        <input type="text" name="filepath" id="filepath" value="<?php echo $data['filepath']; ?>" lay-verify="required" readonly="readonly" autocomplete="off" placeholder="如：文件路径，上传后自动获取" class="layui-input">        
     </div>
     <div class="fileupload">
          <input type="file"  name="upflie" id="upflie" accept="*"/>   
          选择上传文件
      </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">文件标题*</label>
    <div class="layui-input-block" style="width: 500px">
      <input type="hidden" name="addname"  value="<?php echo session('UserName'); ?>">
      <input type="hidden" name="filesize" id="filesize"  value="<?php echo $data['filesize']; ?>">
      <input type="hidden" name="id" value="<?php echo $data['id']; ?>">
      <input type="text" name="name" id="name"  value="<?php echo $data['name']; ?>" lay-verify="required" autocomplete="off" placeholder="如：某某旅游线路线路推荐" class="layui-input">
    </div>
  </div>  
  <div class="layui-form-item">
    <label class="layui-form-label">文件排序</label>
    <div class="layui-input-block" style="width: 500px">
      <input type="number" name="vieworder"  value="<?php echo $data['vieworder']; ?>" lay-verify="required" autocomplete="off" placeholder="排序" class="layui-input" maxlength="30">
    </div>
  </div>   
  <div class="layui-form-item">

    <button class="layui-btn layui-btn-green" type="submit">提交保存</button>

  </div>

</form>

  

</div>   

<script src="/static/js/jquery-1.10.2.min.js" type="application/javascript"></script>
<script src="/static/js/neijqtab.js" type="application/javascript"></script>
<script src="/static/js/xlayui/layui.js" charset="utf-8"></script>
<script>
function initPage(){   

  var objLoading = document.getElementById("LoadingBar");   

  if (objLoading != null){   

    objLoading.style.display = "none";   

    $(".d_contaiter").css("display","block");

  }   

}  

</script>

<script>
layui.use(['form'], function(){
  var form = layui.form(),layer = layui.layer;  
  form.on('select(cid)', function(data){ 
      $.ajax({
          url:"<?php echo url('admin/Category/getType'); ?>",
          dataType:"json",
          async:true,
          data:{cid:data.value},
          type:"get",
          beforeSend:function(){},
          success:function(res){
             var data = res.data;
             var html= "";
             //循环输出数据
             html += '<option value="">搜索或直接选择</option>'; 
             for(var i in data){  
                html += '<option value="'+data[i].id+'">'+data[i].name+'</option>';
             } 
             //赋值
             $("#sid").html(html);
             form.render(); //从新渲染表单
          },
          complete:function(){},
          error:function(){
             alert('请求出错');
          }
      });
  });
});

// 当用户上传时触发事件
  var input=document.getElementById("upflie");
  input.onchange=function(){
      var fileList=this.files;    
      var formData = new FormData();  
      for(var k in fileList){ //文件数组
        formData.append('files[]',fileList[k]);
      } 
      $.ajax({
          url : "<?php echo url('admin/Upload/TempUpload',array('act'=>'uploads')); ?>",
          type : 'POST',
          data : formData,
          // 告诉jQuery不要去处理发送的数据
          processData : false,
          // 告诉jQuery不要去设置Content-Type请求头
          contentType : false,
          dataType:"json",
          success:function(res) {
              if(res.code==200){
                  data = res.data;
                  $("#name").val(data[0].name);
                  $("#filesize").val(data[0].size);
                  $("#filepath").val(data[0].imgpath);
              }
          } 
      });  
  }
</script>
</body>

</html>

